﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SoftHotel.Models;

namespace SoftHotel.Controllers
{
    public class DetalleReservaHabController : Controller
    {
        //
        // GET: /DetalleReservaHab/

        static DetalleReservaHabDAO listadet = new DetalleReservaHabDAO();
        //private static bool vieneDeEditar = false;
        //private static string nombreOriginal = "";
        static ReservaHab reserva;
        static List<DetalleReservaHab> busquedadet;
        static DetalleReservaHabDAO listabusqueda = new DetalleReservaHabDAO();
  

        ReservaHabDAO resdao = new ReservaHabDAO();
        DetalleReservaHabDAO detresdao = new DetalleReservaHabDAO();

        public ActionResult Index()
        {
            listabusqueda.busquedadet = new List<DetalleReservaHab>() { };
            busquedadet = new List<DetalleReservaHab>() { };
            return View();
        }

        //
        // GET: /DetalleReservaHab/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /DetalleReservaHab/Create

        public ActionResult Añadir()
        {
            DetalleReservaHab detalleReservaHab = new DetalleReservaHab();
            return View(detalleReservaHab);
        } 

        //
        // POST: /DetalleReservaHab/Create

        [HttpPost]
        public ActionResult Añadir(DetalleReservaHab detalleReservaHab, string button)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    detresdao.add_detalleReservaHab(detalleReservaHab);
                    return RedirectToAction("Index");
                }
                return View(detalleReservaHab);
            }
            catch
            {
                return View(detalleReservaHab);
            }
        }
        
        //
        // GET: /DetalleReservaHab/Edit/5
 
        public ActionResult Editar(String id)
        {
            DetalleReservaHab detalleReservaHab = new DetalleReservaHab();
            detalleReservaHab = detresdao.consultar_detalleReservaHab(id);
            return View(detalleReservaHab);
        }

        //
        // POST: /DetalleReservaHab/Edit/5

        [HttpPost]
        public ActionResult Editar(String id, DetalleReservaHab detalleReservaHab)
        {
            try
            {
                detresdao.editar_detalleReservaHab(id, detalleReservaHab);
                return RedirectToAction("Index");
            }
            catch
            {
                return View(detalleReservaHab);
            }
        }

        //
        // GET: /DetalleReservaHab/Delete/5
 
        public ActionResult Delete(String id)
        {
            DetalleReservaHab detalleReservaHab = new DetalleReservaHab();
            detalleReservaHab = detresdao.consultar_detalleReservaHab(id);
            return View(detalleReservaHab);
        }

        //
        // POST: /DetalleReservaHab/Delete/5

        [HttpPost]
        public ActionResult Delete(String id, DetalleReservaHab detalleReservaHab)
        {
            try
            {
                detresdao.delete_detalleReservaHab(id);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
